<?php

Class menu_model extends CI_Model{
    
    public function __construct() {
        $this->load->database();
    }
    
    public function get_menu(){
       
       $result = array(); 
       $ret = array();
       $this->db->order_by('id', 'asc');
       $query =  $this->db->get('menu');
       
       $url = uri_string();
       
       $result =  $query->result_array();
       
       $tmp = strpos($url, 'exchange');
       
       foreach ($result as $row){
           if ($row['url']===$url){
               $ret[]= array('id'=>$row['id'], 'name'=>$row['name'], 'url'=>$row['url'], 'active'=>'class="active"');
           }elseIF($row['url']!=='' && strpos($url, $row['url'])!==FALSE){
               $ret[]= array('id'=>$row['id'], 'name'=>$row['name'], 'url'=>$row['url'], 'active'=>'class="active"');
           }else{
               $ret[]= array('id'=>$row['id'], 'name'=>$row['name'], 'url'=>$row['url'], 'active'=>'');
           }
       }
       
       return $ret;
       
       
    }
    
}


?>
